----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 2142 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 180
SPELL.m_sName = "Shield Sla,"
SPELL.m_sToolTip = [[You strike with your shield,
					 dealing moderate damage and
					 knocking back the target.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/shield_slam.png"
SPELL.m_bRequiresTarget = true
SPELL.m_iCoolDown = 9
SPELL.m_iSpellType = SPELLTYPE_SHIELDDAMAGE

---------------------------------------------------------------------------------------

local range = 100
local weapondamage = 10

function SPELL:Cast( pl, target )
	
	if(target && target:IsValid() && target != pl) then
		pl.InSpellAnimation = true
		pl:DoAnimationEvent(ACT_GMOD_GESTURE_MELEE_SHOVE_2HAND)
		pl:EmitSound("devin/blackbetty/player/male/swing_common"..math.random(1,3)..".wav", 100, 100+math.random(-1, -5))
		pl:EmitSound("devin/blackbetty/weapons/swing/2h_"..math.random(1,3)..".wav", 100, 100+math.random(-10,-35))
			timer.Simple(0.35, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					target:EmitSound("devin/blackbetty/weapons/2hMaceHitPlateCrit.wav", 160, 100+math.random(-30,-40))
					ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
					if(SERVER)then
						target:SetVelocity(((pl:GetPos()- Vector(0, 0, 40)) - target:GetPos())*-6.25)
						timer.Simple(0.1, function() 
							local dmginfo = DamageInfo()
								dmginfo:SetDamage( 15 ) --50 damage
								dmginfo:SetDamageType( DMG_CRUSH ) --Bullet damage
								dmginfo:SetAttacker( pl ) --First player found gets credit
								dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) ) --Launch upwards
							target:TakeDamageInfo( dmginfo ) 
						end)
					end
				end
			end)
		timer.Simple(0.4, function()
				pl.InSpellAnimation = false
				pl:SetNWBool("Casting", false)
				pl:SetNWBool("Casted", false)
		end)
	end
end



